namespace xjjxmm.infrastructure.Middleware.RateLimit.RateLimit;

public class RateConfigs
{
    public RateConfig SystemRate { get; set; } = new RateConfig(5, 50);

    public RateConfig ApiRate { get; set; } = new RateConfig(1, 10);
}

public class RateConfig
{
    public RateConfig(int permitRate, int maxPermits)
    {
        PermitRate = permitRate;
        MaxPermits = maxPermits;
    }

    public RateConfig()
    {

    }

    /// <summary>
    /// 最大令牌数量
    /// </summary>
    public int MaxPermits { get; set; }

    /// <summary>
    /// 每秒新增令牌数量
    /// </summary>
    public int PermitRate { get; set; }
}

[Flags]
public enum RateGroup
{
    /// <summary>
    /// 针对每个token
    /// </summary>
    Single = 1,

    /// <summary>
    /// 针对全局的
    /// </summary>
    System = 2
}